package com.github.phoenics.militia.bazookaFx;

import com.github.phoenics.militia.bazookaFx.view.MainLaunchView;
import de.felixroske.jfxsupport.AbstractFxmlView;
import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * main class
 *
 * @author Phoenics Chow
 * on 2019年01月30日
 */
@SpringBootApplication
public class BazookaFx2Application extends AbstractJavaFxApplicationSupport {
    private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BazookaFx2Application.class);
    public static void main(String[] args){
        launch(BazookaFx2Application.class, MainLaunchView.class,args);
    }
    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("程序生成器");
        super.start(stage);
    }
    public static void showView(AbstractFxmlView view, Modality mode,Stage newStage) {
        //AbstractFxmlView view = (AbstractFxmlView)applicationContext.getBean(window);
        //Stage newStage = new Stage();
        Scene newScene;
        if (view.getView().getScene() != null) {
            newScene = view.getView().getScene();
        } else {
            newScene = new Scene(view.getView());
        }

        newStage.setScene(newScene);
        newStage.initModality(mode);
        newStage.initOwner(getStage());
        //newStage.setTitle(view.getDefaultTitle());
        //newStage.initStyle(view.getDefaultStyle());
        newStage.showAndWait();
    }
}
